# Makefile for Hawkeye TCP Server Component

.PHONY: build test run-server run-client clean

# Build the project
build:
	@echo "Building Hawkeye TCP Server Component..."
	go build -o bin/hawkeye ./examples/server_example.go
	go build -o bin/hawkeye-client ./examples/client_example.go

# Run tests
test:
	@echo "Running tests..."
	go test -v ./tests/...

# Run benchmark tests
benchmark:
	@echo "Running benchmark tests..."
	go test -bench=. -benchmem ./tests/

# Run server example
run-server:
	@echo "Starting TCP server..."
	go run ./examples/server_example.go

# Run client example
run-client:
	@echo "Starting TCP client..."
	go run ./examples/client_example.go

# Clean build artifacts
clean:
	@echo "Cleaning build artifacts..."
	rm -rf bin/
	go clean

# Install dependencies
deps:
	@echo "Installing dependencies..."
	go mod tidy
	go mod download

# Run all tests including integration tests
test-all: test benchmark

# Build and run server
server: build
	./bin/hawkeye

# Build and run client
client: build
	./bin/hawkeye-client

# Format code
fmt:
	@echo "Formatting code..."
	go fmt ./...

# Vet code
vet:
	@echo "Vetting code..."
	go vet ./...

# Check code quality
check: fmt vet test

# Default target
all: deps build test

help:
	@echo "Available targets:"
	@echo "  build      - Build the project"
	@echo "  test       - Run tests"
	@echo "  benchmark  - Run benchmark tests"
	@echo "  run-server - Run server example"
	@echo "  run-client - Run client example"
	@echo "  clean      - Clean build artifacts"
	@echo "  deps       - Install dependencies"
	@echo "  check      - Format, vet and test code"
	@echo "  all        - Install deps, build and test"